package com.unitedvision.service.impl;

import java.util.List;

import javax.annotation.Resource;
import javax.persistence.EntityNotFoundException;

import com.unitedvision.persistence.domain.CompanyEntity;
import com.unitedvision.persistence.domain.GoodsEntity;
import com.unitedvision.persistence.domain.InventoryEntity;
import com.unitedvision.persistence.repository.InventoryRepository;
import com.unitedvision.service.InventoryService;

public class InventoryServiceImpl implements InventoryService {

	@Resource
	private InventoryRepository inventoryRepository;
	
	@Override
	public void save(InventoryEntity inventory) {
		inventoryRepository.save(inventory);
	}

	@Override
	public void delete(InventoryEntity inventory) {
		inventoryRepository.delete(inventory);
	}

	@Override
	public InventoryEntity get(int id) throws EntityNotFoundException {
		return inventoryRepository.findOne(id);
	}

	@Override
	public List<InventoryEntity> getAll() throws EntityNotFoundException {
		return inventoryRepository.findAll();
	}

	@Override
	public List<InventoryEntity> getByCompany(CompanyEntity company) throws EntityNotFoundException {
		return inventoryRepository.findByCompany(company);
	}

	@Override
	public List<InventoryEntity> getByGoods(GoodsEntity goods) throws EntityNotFoundException {
		return inventoryRepository.findByGoods(goods);
	}

	@Override
	public long count() {
		return inventoryRepository.count();
	}
}
